/**
 * 三维工具集
 */

const fly = require("./fly");



function ThreeToolsExample(toolmanager) {
    this._toolManager = toolmanager;
};

ThreeToolsExample.prototype.initUI = function () {

    var _this = this;

    var rightPanel = document.getElementById("right");

    var accordion = document.createElement('div');
    accordion.id = "accordion";
    accordion.style.height = "100%";

    rightPanel.appendChild(accordion);

    var title = document.createElement('h3');
    title.innerHTML = '工具';

    accordion.appendChild(title);

    var contentPanel = document.createElement('div');
    accordion.appendChild(contentPanel);
 

    var pointMeasure = document.createElement('input');
    //var text=document.createComment("Comment");
    pointMeasure.type = "checkbox";
    pointMeasure.name = "点测量";


    pointMeasure.onchange = function () {
    var curTool = _this._toolManager.CreateMeasurePointTool();
    _this._toolManager.setCurrentTool(curTool);
    };
    contentPanel.appendChild(pointMeasure);

    
    contentPanel.appendChild(document.createTextNode("点测量"));
    
    
    contentPanel.appendChild(document.createElement("br")); 

    var lengthMeasure = document.createElement('input');
    lengthMeasure.type = "checkbox";
    lengthMeasure.name = "线测量";
    
    lengthMeasure.onchange = function () {
    var curTool = _this._toolManager.CreateMeasureLengthTool();
    _this._toolManager.setCurrentTool(curTool);
    };

    contentPanel.appendChild(lengthMeasure);
    contentPanel.appendChild(document.createTextNode("线测量"));
    contentPanel.appendChild(document.createElement("br")); 

    var sectionSelection = document.createElement('input');
    sectionSelection.type = "checkbox";
    sectionSelection.name = "部件选择";
    sectionSelection.onchange = function () {
        var curTool = this._toolManager.CreateSelectionSectionTool();
        this._toolManager.setCurrentTool(curTool);
    };
    contentPanel.appendChild(sectionSelection);
    contentPanel.appendChild(document.createTextNode("部件选择"));
    contentPanel.appendChild(document.createElement("br")); 
    

    


    var landLengthMeasure = document.createElement('input');
    landLengthMeasure.type = "checkbox";
    landLengthMeasure.name = "贴地线测量";
    landLengthMeasure.onchange = function () {

        var curTool = this._toolManager.CreateMeasureLengthTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(landLengthMeasure);
    contentPanel.appendChild(document.createTextNode("贴地线测量"));
    contentPanel.appendChild(document.createElement("br")); 

    var rightAngleMeasure = document.createElement('input');
    rightAngleMeasure .type = "checkbox";
    rightAngleMeasure .name = "直角测量";
    rightAngleMeasure .onchange = function () {

        var curTool = this._toolManager.CreateMeasureRightAngleTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(rightAngleMeasure);
    contentPanel.appendChild(document.createTextNode("直角测量"));
    contentPanel.appendChild(document.createElement("br")); 


    var circleAreaMeasure = document.createElement('input');
    circleAreaMeasure.type = "checkbox";
    circleAreaMeasure.name = "圆面积测量"
    circleAreaMeasure.onchange = function () {

        var curTool = this._toolManager.CreateMeasureAreaTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(circleAreaMeasure);
    contentPanel.appendChild(document.createTextNode("圆面积测量"));
    contentPanel.appendChild(document.createElement("br")); 


    var polygonAreaMeasure = document.createElement('input');
    polygonAreaMeasure.type = "checkbox";
    polygonAreaMeasure.name = "多边形面积测量";
    polygonAreaMeasure.onchange = function () {

        var curTool = this._toolManager.CreateMeasureAreaTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(polygonAreaMeasure);
    contentPanel.appendChild(document.createTextNode("多边形面积测量"));
    contentPanel.appendChild(document.createElement("br")); 


    var floodRegion = document.createElement('input');
    floodRegion.type = "checkbox";
    floodRegion.name = "淹没分析";
    floodRegion.onchange = function () {

        var curTool = this._toolManager.CreateRegionFloodTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(floodRegion);
    contentPanel.appendChild(document.createTextNode("淹没测量"));
    contentPanel.appendChild(document.createElement("br")); 


    var digging = document.createElement('input');
    digging.type = "checkbox";
    digging.name = "挖坑";
    digging.onchange = function () {

        var curTool = this._toolManager.CreateGeologyAnalysisAreaTool();
        curTool.SetGeoXmlString("<?xml version='1.0' encoding='legacy'?><Geology> <Drill name='ZK1' pos='116.1781390,39.9780674,8.746' water_depth='2.5'><layer name='冲填土' texture='冲填土.jpg' depth='5.1'><Attribute name='岩性描述' value='黄土层' unit=''/><Attribute name='地质年代' value='侏罗纪' unit=''/></layer></Drill></Geology>");
        curTool.SetTextureAddr("../SamplesResource/GeoTexture/");
        this._toolManager.setCurrentTool(tool); //挖坑
        sceneControl.AttachEvent("OnAreaAnalysisSelected", areaSelect);

    };
    contentPanel.appendChild(digging);
    contentPanel.appendChild(document.createTextNode("挖坑"));
    contentPanel.appendChild(document.createElement("br")); 


    var areaGeologyAnalysis = document.createElement('input');
    areaGeologyAnalysis.type = "checkbox";
    areaGeologyAnalysis.name = "面剖切";
    areaGeologyAnalysis.onchange = function () {

        var curTool = this._toolManager.CreateGeologyAnalysisAreaTool();
        curTool.GeologyAnalysisStyle = 2;
        curTool.SetGeoXmlString("<?xml version='1.0' encoding='legacy'?><Geology> <Drill name='ZK1' pos='116.1781390,39.9780674,8.746' water_depth='2.5'><layer name='冲填土' texture='冲填土.jpg' depth='5.1'><Attribute name='岩性描述' value='黄土层' unit=''/><Attribute name='地质年代' value='侏罗纪' unit=''/></layer></Drill></Geology>");
        curTool.SetTextureAddr("../SamplesResource/GeoTexture/");
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(areaGeologyAnalysis);
    contentPanel.appendChild(document.createTextNode("面剖切"));
    contentPanel.appendChild(document.createElement("br")); 


    var lineGeologyAnalysis = document.createElement('input');
    lineGeologyAnalysis.type = "checkbox";
    lineGeologyAnalysis.name = "线剖切";
    lineGeologyAnalysis.onchange = function () {

        var curTool = this._toolManager.CreateGeologyAnalysisLineTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(lineGeologyAnalysis);
    contentPanel.appendChild(document.createTextNode("线剖切"));
    contentPanel.appendChild(document.createElement("br")); 


    var pointToPoint = document.createElement('input');
    pointToPoint.type = "checkbox";
    pointToPoint.name = "点对点";
    pointToPoint.onchange = function () {

        var curTool = this._toolManager.CreateAnalysis3DVisibilityTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(pointToPoint);
    contentPanel.appendChild(document.createTextNode("点对点"));
    contentPanel.appendChild(document.createElement("br")); 


    var pointToLine = document.createElement('input');
    pointToLine.type = "checkbox";
    pointToLine.name = "点对线";
    pointToLine.onchange = function () {

        var curTool = this._toolManager.CreateAnalysis3DVisibilityTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(pointToLine);
    contentPanel.appendChild(document.createTextNode("点对线"));
    contentPanel.appendChild(document.createElement("br")); 


    var pointToSurface = document.createElement('input');
    pointToSurface.type = "checkbox";
    pointToSurface.name = "点对面";
    pointToSurface.onchange = function () {

        var curTool = this._toolManager.CreateAnalysis3DVisibilityTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(pointToSurface);
    contentPanel.appendChild(document.createTextNode("点对面"));
    contentPanel.appendChild(document.createElement("br")); 


    var clear = document.createElement('input');
    clear.type = "checkbox";
    clear.name = "清除剖切";
    clear.onchange = function () {

        var curTool = this._toolManager.ClearTool();
        this._toolManager.setCurrentTool(curTool);

    };
    contentPanel.appendChild(clear);
    contentPanel.appendChild(document.createTextNode("清除剖切"));
    contentPanel.appendChild(document.createElement("br"));


    $("#accordion").accordion({
        heightStyle: "fill"
    });


};


module.exports = ThreeToolsExample;